package com.mnnu.stategypattern;

import java.util.function.IntPredicate;

public enum UserType {

    COMMON( recharge-> recharge > 0 && recharge < 100),
    SUPER(recharge -> recharge >= 100 && recharge < 1000),
    PERSONAL(recharge -> recharge >= 1000);

    private final IntPredicate support;

    UserType(IntPredicate support) {
        this.support = support;
    }

    public static UserType typeOf(int recharge) {
        for (UserType value : values()) {
            if (value.support.test(recharge)) {
                return value;
            }
        }
        return null;
    }
}
